package org.addressBook.bean;

import java.util.List;

public class PageInfo<T> {
    /**
     * pageNum 当前页
     * pageSize 每页的条数
     * 数据集合 List<T> resultList
     * total 总条数
     * allPage 总页数
     */
    private Integer pageNum;
    private Integer pageSize;
    private List<T> resultList;
    private Integer total;
    private Integer allPage;

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getResultList() {
        return resultList;
    }

    public void setResultList(List<T> resultList) {
        this.resultList = resultList;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
        setAllPage();
    }

    public Integer getAllPage() {
        return allPage;
    }

    public void setAllPage() {
        //总页数 = 总条数 / 每页条数 ？ 有余数 结果+1
        if(this.total % this.pageSize == 0){
            this.allPage = this.total / this.pageSize;
        }else {
            this.allPage = (this.total / this.pageSize) + 1;
        }
    }
}
